#! /usr/bin/env python

import pygame

class Sprite(pygame.sprite.Sprite):
        
    def __init__(self, centerPoint, image):
        pygame.sprite.Sprite.__init__(self) 
        """Set the image and the rect"""
        self.image = image
        self.rect = image.get_rect()
        """Move the rect into the correct position"""
        self.rect.center = centerPoint
        
class Sprite2(pygame.sprite.DirtySprite):
        
    def __init__(self, centerPoint, image):
        pygame.sprite.Sprite.__init__(self) 
        """Set the image and the rect"""
        self.image = image
        self.rect = image.get_rect()
        """Move the rect into the correct position"""
        self.rect.center = centerPoint        
                
class Pellet(pygame.sprite.Sprite):
        
    def __init__(self, top_left, image = None):
        pygame.sprite.Sprite.__init__(self) 
        
        if image == None:
            self.image, self.rect = load_image('pellet.png',-1)
        else:
            self.image = image
            self.rect = image.get_rect()
        
        self.rect.topleft = top_left
       
class TextSprite(pygame.sprite.Sprite):

    RED = (255, 0, 0)
    GREEN = (0, 255, 0)
    BLUE = (0, 0, 255)
    BLACK = (0, 0, 0)
    WHITE = (255, 255, 255)
     
    def __init__(self, centerPoint, text, color=WHITE, fontarg=None,
                 fontsize=36):
        pygame.sprite.Sprite.__init__(self)
        """Set the text and the rect"""
        self.text = text
        self.color = color
        self.font = fontarg
        self.fontsize = fontsize
        if pygame.font:
            font = pygame.font.Font(self.font, self.fontsize)
            self.image = font.render(self.text, 1, self.color)
        else:
            print "ERROR: pygame.font not found!"
        self.rect = self.image.get_rect()
        """Move the rect into the correct position"""
        self.rect.center = centerPoint

    def update(self):
        if pygame.font:
            font = pygame.font.Font(self.font, self.fontsize)
            self.image = font.render(self.text, 1, self.color)
            self.rect = self.image.get_rect(center = self.rect.center)
        else:
            print "ERROR: pygame.font not found!"
